//
//  ViewController.m
//  视频播放
//
//  Created by clz on 2019/10/2.
//  Copyright © 2019 clz. All rights reserved.
//

#import "ViewController.h"
#import <AVKit/AVKit.h>

@interface ViewController ()

@property(nonatomic,strong)AVPlayerViewController *playerVC;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
/*
 Apple为我们提供了多种方法来实现视频播放，包括
 MPMoviePlayerController，
 MPMoviePlayerViewController，
 AVPlayer，
 AVPlayerViewController等。而值得注意的是，上述的MPMoviePlayerController与MPMoviePlayerViewController在iOS9.0之后被弃用
 */
    NSString *videoUrl = @"http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4";
    
    //m3u8
    self.playerVC = [[AVPlayerViewController alloc]init];
//    [NSURL fileURLWithPath:videoUrl];
    self.playerVC.player = [AVPlayer playerWithURL:[NSURL URLWithString:videoUrl]];
    self.playerVC.view.frame = CGRectMake(0, 0, self.view.frame.size.width, 300);
    self.playerVC.showsPlaybackControls = YES;
    self.playerVC.exitsFullScreenWhenPlaybackEnds = YES;
    [self.view addSubview:self.playerVC.view];
    if (self.playerVC.readyForDisplay) {
        [self.playerVC.player play];
    }
    
    
    
    
}




@end
